home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Online / hsc / source / ugly / expstr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-02  |  3.8 KB  |  120 lines

  1. /*
  2.  * This source code is part of hsc, a html-preprocessor,
  3.  * Copyright (C) 1993-1997  Thomas Aglassinger
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20. #ifndef UGLY_EXPSTR_H
  21. #define UGLY_EXPSTR_H
  22.  
  23. /*
  24.  * ugly/expstr.h
  25.  *
  26.  * self-expanding string functions, header
  27.  *
  28.  * (W) by Tommy-Saftwörx in 1995
  29.  *
  30.  */
  31.  
  32. #include <stddef.h>
  33.  
  34. #include "utypes.h"
  35.  
  36. #define EXPSTR_MEMSTEP 96
  37. #define ES_MIN_MEMSTEP 8        /* min. memory step for init( step_size ) */
  38.  
  39. #ifndef modadj
  40. #define modadj(x,by) ((by)*(((x)+(by))/(by)))
  41. #endif
  42.  
  43. /* some inline macros used without DEBUG defined */
  44. #define ugly_inline_estr2str(es) ((es)->es_data)
  45. #define ugly_inline_estrlen(es)  ((es)->es_len - 1)
  46.  
  47. typedef struct
  48. {
  49.     STRPTR es_data;             /* ptr to string data */
  50.     size_t es_len;              /* current len */
  51.     size_t es_size;             /* current size of mem allocated */
  52.     size_t es_step;             /* size of memory step */
  53. }
  54. EXPSTR;
  55.  
  56. /*
  57.  * external prototypes
  58.  */
  59.  
  60. #ifndef NOEXTERN_UGLY_EXPSTR_H
  61.  
  62. extern EXPSTR *ugly_dbg_init_estr(size_t step_size, STRPTR file, ULONG line);
  63. extern EXPSTR *ugly_init_estr(size_t step_size);
  64. extern void del_estr(EXPSTR * es);
  65.  
  66. extern BOOL ugly_clr_estr(EXPSTR * es);
  67. extern BOOL ugly_dbg_clr_estr(EXPSTR * es, STRPTR file, ULONG line);
  68. extern BOOL set_estrn(EXPSTR * es, CONSTRPTR s, size_t n);
  69.  
  70. extern BOOL ugly_set_estr(EXPSTR * es, CONSTRPTR s);
  71. extern BOOL ugly_app_estrch(EXPSTR * es, int ch);
  72. extern BOOL ugly_app_estr(EXPSTR * es, CONSTRPTR s);
  73.  
  74. extern BOOL ugly_dbg_set_estr(EXPSTR * es, CONSTRPTR s, STRPTR file, ULONG line);
  75. extern BOOL ugly_dbg_app_estrch(EXPSTR * es, int ch, STRPTR file, ULONG line);
  76. extern BOOL ugly_dbg_app_estr(EXPSTR * es, CONSTRPTR s, STRPTR file, ULONG line);
  77. extern STRPTR ugly_estr2str(EXPSTR * es);
  78. extern size_t ugly_estrlen(EXPSTR * es);
  79.  
  80. extern BOOL estrcpy(EXPSTR * dest, EXPSTR * src);
  81. extern BOOL estrcat(EXPSTR * dest, EXPSTR * src);
  82.  
  83. extern BOOL get_mid_estr(EXPSTR * dest, EXPSTR * src, size_t from, size_t num);
  84. extern BOOL get_right_estr(EXPSTR * dest, EXPSTR * src, size_t num);
  85. extern BOOL get_left_estr(EXPSTR * dest, EXPSTR * src, size_t num);
  86.  
  87. #endif /* NOEXTERN_UGLY_EXPSTR_H */
  88.  
  89. /*
  90.  * debugging prototypes
  91.  */
  92. #if DEBUG_UGLY_EXPSTR
  93.  
  94. /* full debugging */
  95. #define set_estr_mem( es, size ) ugly_dbg_set_estr_mem( es, size, __FILE__, __LINE__ )
  96. #define set_estr( es, s ) ugly_dbg_set_estr( es, s, __FILE__, __LINE__ )
  97. #define app_estrch( es, ch ) ugly_dbg_app_estrch( es, ch, __FILE__, __LINE__ )
  98. #define app_estr( es, s ) ugly_dbg_app_estr( es, s, __FILE__, __LINE__ )
  99. #define init_estr( s ) ugly_dbg_init_estr( s, __FILE__, __LINE__ )
  100. #define clr_estr( s ) ugly_dbg_clr_estr( s, __FILE__, __LINE__ )
  101. #define estr2str( s ) ugly_estr2str( s )
  102. #define estrlen( s ) ugly_estrlen( s )
  103.  
  104. #else
  105.  
  106. /* no debugging */
  107. #define set_estr_mem( es, size ) ugly_set_estr_mem( es, size )
  108. #define set_estr( es, s ) ugly_set_estr( es, s )
  109. #define app_estrch( es, ch ) ugly_app_estrch( es, ch )
  110. #define app_estr( es, s ) ugly_app_estr( es, s )
  111. #define init_estr( s ) ugly_init_estr( s )
  112. #define clr_estr( s ) ugly_clr_estr( s )
  113. #define estr2str( s ) ugly_inline_estr2str( s )
  114. #define estrlen( s ) ugly_inline_estrlen( s )
  115.  
  116. #endif
  117.  
  118. #endif /* UGLY_EXPSTR_H */
  119.  
  120.